package cn.wolfcode.trip.admin.controller;

import cn.wolfcode.trip.base.domain.VisaManager;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IVisaService;
import cn.wolfcode.trip.base.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("visaManager")
public class VisaManagerController {

    @Autowired
    private IVisaService visaService;


    @RequestMapping("list")
    public String list(@ModelAttribute("qo") QueryObject qo, Model model){
        model.addAttribute("result",visaService.selectForListManager(qo));
        return "visaManager/list";
    }


    @RequestMapping("saveOrUpdate")
    @ResponseBody
    public JSONResult saveOrUpdate(VisaManager visaManager){
        JSONResult result = new JSONResult();
        try {
            visaService.save(visaManager);
        }catch (Exception e){
            e.printStackTrace();
            result.mark(e.getMessage());
        }
        return result;
    }
}
